package app.goods.info.views.listeners;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;

import app.goods.info.utils.InterfaceUtils;

public class QuantityCellEditorListener implements CellEditorListener {
	private JFrame frame;

	public QuantityCellEditorListener(JFrame frame) {
		super();
		this.frame = frame;
	}

	@Override
	public void editingStopped(ChangeEvent e) {
		/**
		 * 1、遍历左侧上方商品名称表，取出数量不为零的商品名称，与右侧商品列表对比，更新所有匹配的商品数量，，更新表数据 <br>
		 * 2、遍历左侧供应商名称，与右侧商品列表对比，根据供应商名称匹配，计算每个供应商的商品总价格，更新表数据
		 * 3、每次编辑数量或者单独刷新某一个品类数据之后，都执行一次这个逻辑
		 */
		EventQueue.invokeLater(() -> {
			InterfaceUtils.cacaulateTotalPrice(frame);
		});

	}

	@Override
	public void editingCanceled(ChangeEvent e) {
		// TODO Auto-generated method stub

	}

}
